<?

if(!defined(SCOT_TAG_SERIALIZER)) {
	define('SCOT_TAG_SERIALIZER', true);

	class TagSerializer {
		var $scotModel = null;
		function TagSerializer($model) {
			if(SCOT_DEBUG) echo('Call : TagSerializer->RDFSerializer()<br>');
			
			$this->scotModel = $model;
		}
		
		function serialize($path) {
			if(SCOT_DEBUG) echo('Call : TagSerializer->serialize()<br>');
			
			$data = "TAG,A FREQUENCY,R FREQUENCY\n";
			
			foreach($this->scotModel->getTagList() as $tag) {
				$data .= $tag->getName().",";
				$data .= $tag->getAFrequency().",";
				$data .= sprintf("%1\$.2f", $tag->getRFrequency($this->scotModel->getTotalTagFrequency()))."\n";
			}
			
			$data .= "TOTAL,".($this->scotModel->getTotalTagFrequency()).",100\n";
			
			$fh = fopen($path, 'w');
			fwrite($fh, $data);
			fclose($fh);
		}
	}
}
?>